<?php

namespace app\common\model;


class VideoChannel extends BaseModel
{


    // 表名
    protected $name = 'video_channel';


    // 追加属性
    protected $append = [
        'type_text'
    ];


    public function getTypeList()
    {
        return [
            '1' => __('Type 1'),
            '2' => __('Type 2'),
            '3' => __('Type 3'),
            '4' => __('Type 4'),
            '5' => __('Type 5'),
            '6' => __('Type 6'),
            '7' => __('Type 7'),
            '8' => __('Type 8'),
            '9' => __('Type 9'),
            '10' => __('Type 10'),
            '11' => __('Type 11'),
            '12' => __('Type 12'),
            '13' => __('Type 13'),
            '14' => __('Type 14'),
            '15' => __('Type 15'),
            '16' => __('Type 16'),
            '17' => __('Type 17'),
            '18' => __('Type 18'),
            '19' => __('Type 19'),
            '20' => __('Type 20'),
            '21' => __('Type 21'),
            '22' => __('Type 22'),
            '23' => __('Type 23'),
            '24' => __('Type 24'),
            '25' => __('Type 25'),
            '26' => __('Type 26'),
        ];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function video()
    {
        return $this->belongsTo('Video', 'video_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
